package com.wbl.train.business.config;

import com.wbl.train.common.intderceptor.MemberInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 王博纶
 * @since 2023-1-26
 * @description member模块的配置类，开启指定的拦截器
 */
@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {

   @Autowired
   MemberInterceptor memberInterceptor;

   @Override
   public void addInterceptors(InterceptorRegistry registry) {

       // 开启会员登录信息拦截器
       registry.addInterceptor(memberInterceptor)
               // 添加要拦截的路径
               .addPathPatterns("/**")
               // 排除不需要拦截的路径
               .excludePathPatterns(
                       "/hello"
               );
   }
}
